package com.css.modules.lawRepo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.css.common.utils.PageUtils;
import com.css.common.utils.Query;
import com.css.modules.lawRepo.dao.LawRepoDownloadDao;
import com.css.modules.lawRepo.entity.LawRepoDownloadEntity;
import com.css.modules.lawRepo.service.LawRepoDownloadService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;
import java.util.UUID;


@Service
public class LawRepoDownloadServiceImpl extends ServiceImpl<LawRepoDownloadDao, LawRepoDownloadEntity> implements LawRepoDownloadService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<LawRepoDownloadEntity> page = this.page(
                new Query<LawRepoDownloadEntity>().getPage(params),
                new QueryWrapper<LawRepoDownloadEntity>()
        );
        return new PageUtils(page);
    }

    @Override
    public LawRepoDownloadEntity  insert(LawRepoDownloadEntity downloadEntity) {
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        downloadEntity.setTablerowguid(uuid);
        downloadEntity.setCreatorId("creatorId");
        downloadEntity.setCreateTime(new Date());
        downloadEntity.setDelFlag("2");
        this.save(downloadEntity);
        return downloadEntity;
    }

}
